package com.zxd.net_app;

import java.net.InetAddress;

/**
 * ClassName:NetAddressTest
 * Package:com.zxd.net_app
 *
 * @Date:2023/9/28 15:57
 * @Author:zxde
 */
public class NetAddressTest {
    public static void main(String[] args) throws Exception{
        //获取本机的Ip地址对象
        InetAddress localHost = InetAddress.getLocalHost();

        InetAddress baiduAddress = InetAddress.getByName("www.baidu.com");
        String baiduHostName = baiduAddress.getHostName();
        String baiduHostAddress = baiduAddress.getHostAddress();


        //判断是否可以与百度连通
        boolean reachable = baiduAddress.isReachable(6000);

        System.out.println("-----------------");
    }
}
